﻿package UIComponents
{
	import fl.events.ComponentEvent;
	
	import flash.display.DisplayObject;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.text.TextField;
	
	public class NPCDialogue extends Sprite
	{
		private var npcContext:TextField;
		private var npcIcon:IconContainer;
		private var npcBtn:DisplayObject;
		public function NPCDialogue()
		{
			init();
		}
		
		private function init():void
		{
			this.npcContext=this.getChildByName("npcContext") as TextField;	
			this.npcContext.mouseEnabled=false;
			this.npcIcon=this.getChildByName("NPCIcon") as IconContainer;
			this.npcBtn=this.getChildByName("npcBtn");
			this.npcBtn.addEventListener(MouseEvent.CLICK,clickFun);
		}
		
		private function clickFun(e:MouseEvent):void
		{
			this.dispatchEvent(new MouseEvent("npcBtnEvent"));
		}
		
		public function setNPCInfo(icon:DisplayObject=null,npcTxt:String=""):void
		{
			reset();
			this.npcContext.text=npcTxt;
			this.npcIcon.addPic(icon);
		}
		
		private function reset():void
		{
			this.npcContext.text="";
			this.npcIcon.addPic(null);
		}
		
		
	}
}